// 深克隆
export function deepClone(data) {
  if (typeof data !== 'object' || data === null) {
    return data;
  }

  let result = Array.isArray(data) ? [] : {};
  for (let key in data) {
    if (data.hasOwnProperty(key)) {
      result[key] = deepClone(data[key]);
    }
  }

  return result;
}

// 防抖函数
export function debounce(func, delay = 300) {
  let timer;
  return function () {
    clearTimeout(timer);
    timer = setTimeout(() => {
      func.apply(this, arguments);
    }, delay);
  };
}

// 处理列表序号
export function handleIndex(index, pageOptions) {
  const resIndex = index + (pageOptions.currentPage - 1) * pageOptions.pageSize;
  return resIndex + 1;
}
